<?php

class MyConstants
{
	
    /**
	 * 
	 * State constants
	 */
	const STATE_NEW             = 1;
    const STATE_APPROVED        = 2;
    const STATE_DELETED         = 3;
    const STATE_FAILED          = 4;
    const STATE_COMPLETED       = 5;
    const STATE_PENDING_PAYMENT = 6;
    const STATE_USED            = 7;
    const STATE_UNAVAILABLE     = 8;
    const STATE_PAYMENT_REJECTED = 10;
    //====end  State constants====
	
    const STATUS_NEW             = 1;
    const STATUS_APPROVED        = 2;
    const STATUS_DELETED         = 3;
    const STATUS_FAILED          = 4;
    const STATUS_COMPLETED       = 5;
    const STATUS_PENDING_DELETE  = 6;
    const STATUS_USED            = 7;
    const STATUS_UNAVAILABLE	 = 8;
    const STATUS_PAID_PENDING_INFO = 9;
    const STATUS_PAYMENT_REJECTED  = 10;
    const STATUS_PENDING_PAYMENT = 11;
    const STATUS_FALSE_AMOUNT    = 12;

    const TYPE_NEWS              = 3;

    const IMPORT_STATUS_NEW       = 1;
    const IMPORT_STATUS_COMPLETED  = 2;
    const IMPORT_STATUS_DELETED   = 3;
    const IMPORT_STATUS_FORMATERROR = 4;
    const IMPORT_STATUS_PARSEERROR = 5;
    
    const ROLE_ADMIN            = 1;
    const ROLE_NEWS_ADMIN       = 2;
    const ROLE_TEXT_ADMIN       = 3;
    const ROLE_FORUM_ADMIN      = 4;
#    const ROLE_MEDIC            = 5;
    const ROLE_USER             = 6;

    const OBJ_STATUS_ACTIVE    = 1;
    const OBJ_STATUS_INACTIVE  = 2;
    const OBJ_STATUS_DELETED   = 3;
    
    //undefined object id - example for anonymous user
    const UNDEFINED_ID         = -1;

    //List of parent categories
    const GALLERY_PHOTO        = 1;
    const GALLERY_VIDEO        = 2;
    
    public static function getCurrencyConverter()
    {
        return $arConverter = array(
		                       'LTL_EUR' => 0.2896
		                       , 'LTL_USD' => 0.3827
		                       , 'EUR_LTL' => 3.4528
		                       , 'EUR_USD' => 1.3213
		                       , 'USD_LTL' => 2.6132
		                       , 'USD_EUR' => 0.7568
		                       );
    }
    
    public static function isMultiLng()
    {
        return true;
        //return false;
    }
    //member module constants
    public static function getRolesList()
    {
        return array(
            MyConstants::ROLE_ADMIN => 'Admin'
            , MyConstants::ROLE_USER => 'User'
        );
    }

    public static function getStatusList()
    {
        return array(
            MyConstants::STATUS_NEW => sfContext::getInstance()->getI18N()->__('status_new')
            , MyConstants::STATUS_APPROVED => sfContext::getInstance()->getI18N()->__('status_approved')
            , MyConstants::STATUS_DELETED => sfContext::getInstance()->getI18N()->__('status_deleted')
            , MyConstants::STATUS_FAILED => sfContext::getInstance()->getI18N()->__('status_failed')
            , MyConstants::STATUS_COMPLETED => sfContext::getInstance()->getI18N()->__('status_completed')
            , MyConstants::STATUS_PENDING_DELETE => sfContext::getInstance()->getI18N()->__('pending delete')
            , MyConstants::STATUS_USED => sfContext::getInstance()->getI18N()->__('used')
            , MyConstants::STATUS_UNAVAILABLE => sfContext::getInstance()->getI18N()->__('unaviable')
            , MyConstants::STATUS_PAID_PENDING_INFO => sfContext::getInstance()->getI18N()->__('payd, but pending info')
            , MyConstants::STATUS_PAYMENT_REJECTED => sfContext::getInstance()->getI18N()->__('payment rejected')
            , MyConstants::STATUS_PENDING_PAYMENT => sfContext::getInstance()->getI18N()->__('pending payment')
            , MyConstants::STATUS_FALSE_AMOUNT => sfContext::getInstance()->getI18N()->__('false amount')
         );
    }

    public static function getObjStatusList()
    {
        return array(
            MyConstants::OBJ_STATUS_ACTIVE => 'Active'
            , MyConstants::OBJ_STATUS_INACTIVE => 'Inactive'
            , MyConstants::OBJ_STATUS_DELETED => 'Deleted'
        );
    }
    
    public static function getStatusName($name)
    {
        switch($name)
        {
            case MyConstants::STATUS_NEW:
                return sfContext::getInstance()->getI18N()->__('new');
            case MyConstants::STATUS_APPROVED:
                return sfContext::getInstance()->getI18N()->__('approved');
            case MyConstants::STATUS_DELETED:
                return sfContext::getInstance()->getI18N()->__('deleted');
            case MyConstants::STATUS_FAILED:
                return sfContext::getInstance()->getI18N()->__('failed');
            case MyConstants::STATUS_COMPLETED:
                return sfContext::getInstance()->getI18N()->__('completed');

            case MyConstants::OBJ_STATUS_ACTIVE:
                throw new Exception('MyConstants::OBJ_STATUS_ACTIVE is not valid in MyConstants::getStatusName!!!');
                return 'Active';
            case MyConstants::OBJ_STATUS_INACTIVE:
                return sfContext::getInstance()->getI18N()->__('Inactive');
            case MyConstants::OBJ_STATUS_DELETED:
                return sfContext::getInstance()->getI18N()->__('Deleted');
        }

        return $name;
    }

    /**
    *   Returns languages allowed for project (from app_lng_in_use)
    *   @return array of languages ( array('lt' => 'LT') )
    */
    public static function getLngList()
    {
        $arLng = sfConfig::get('app_lng_in_use');
        if( empty($arLng) )
            $arLng = array('lt' => 'LT');

        return $arLng;
    }


    // Use as folder, by default
    const MODULE_VIRTUAL        = 0;
    const TYPE_TEXTMODULE       = 1;
    const TYPE_GALLERY          = 2;
    const TYPE_PRODUCT          = 5;
    const TYPE_CATEGORY         = 6;
    // used in Tree to indicate link
    const TYPE_LINK_TO          = 7;
    // used in import for insert in storage
    const TYPE_IMPORT           = 8;
    const TYPE_TREE_PAGE        = 9;
    const TYPE_SUBSCRIBER       = 10;
    const TYPE_USER             = 11;
    const TYPE_FAQ              = 12;
    
    /**
    *   Returns list of installed modules
    */
    public static function getModuleTypeList()
    {
        return array(
            MyConstants::TYPE_TEXTMODULE => 'textmodule'
            , MyConstants::TYPE_PRODUCT => 'pradmin'
            , MyConstants::TYPE_GALLERY => 'gallery'
            , MyConstants::TYPE_CATEGORY => 'category'
            , MyConstants::TYPE_SUBSCRIBER => 'subscriber'
            , MyConstants::MODULE_VIRTUAL => 'folder'
            , MyConstants::TYPE_LINK_TO => 'linkto'
            , MyConstants::TYPE_NEWS => 'news'
        );        
    }

    /**
    *   Returns module name by its ID
    *   @param integer $name ID of module
    *   @return string module name
    */
    public static function getTypesList()
    {
        return array(
           MyConstants::TYPE_TEXTMODULE => 'text'
           , MyConstants::TYPE_GALLERY => 'gallery'
           , MyConstants::TYPE_CATEGORY => 'category'
           , MyConstants::MODULE_VIRTUAL => 'folder'
        );
    }

    public static function getModuleTypeName($name)
    {
        switch($name)
        {
            case MyConstants::MODULE_VIRTUAL:
                return 'folder';
            case MyConstants::TYPE_TEXTMODULE:
                return 'photos with text';
            case MyConstants::MODULE_GALLERY:
                return 'photo gallery';
        }

        return $name;
    }

    /**
    *   Returns currencies allowed for project (from app_currency_in_use)
    *   @return array of currencies ( array('lt' => 'LTL') )
    */
    public static function getCurrencyInUse()
    {
        $arCurrency = sfConfig::get('app_currency_in_use');
        if( empty($arCurrency) )
            $arCurrency = array('lt' => 'LTL');

        return $arCurrency;
    }


}

?>
